<template>
  <div>
    <customDialog
      :title="`同步任务详情`"
      :dialogVisible="dialogVisible"
      @close="dialogVisible = false"
      :showFoot="false"
      width="800"
    >
      <div class="table_box_wrapper">
        <custom-table
          :loading="loading"
          :columns="columns"
          :tableData="tableData"
          :isPagination="false"
          :maxHeight="500"
          class="table_box"
        >
          <template #vodFileName="{ scope }">
            <el-tooltip
              :content="scope.row?.vodFileId"
              placement="bottom"
              effect="light"
            >
              <span>{{ scope.row?.vodFileName }}</span>
            </el-tooltip>
          </template>
        </custom-table>
      </div>
    </customDialog>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, toRefs } from "vue";
import customTable from "@/components/CustomTable/index.vue";
import customDialog from "@/components/CustomDialog/index.vue";

const dialogVisible = ref(false);
const loading = ref<boolean>(false);
const tableData = ref<Array<any>>([]);

const columns = reactive([
  { prop: "id", label: "小程序Id", minWidth: 50 },
  { prop: "appName", label: "小程序名称", minWidth: 80 },
  { prop: "errorMessage", label: "备注", minWidth: 200 },
]);

// 父级电子显示dialog
const showDialog = (val: Array<any>) => {
  // console.log("---显示分配分销商----**----", val);
  dialogVisible.value = true;
  if (val && val.length) {
    tableData.value = val.map((item: Record<string, any>) => {
      return {
        id: item.miniApp.id,
        appName: item.miniApp.appName,
        errorMessage: item?.successful
          ? "已成功提交审核"
          : `提交失败：${item.errorMessage}`,
      };
    });
  }
};

defineExpose({
  showDialog,
});
</script>

<style scoped lang="scss">
.search_box {
  padding-left: 0;

  :deep(.el-form-item) {
    margin-bottom: 10px;
  }
}

.table_box_wrapper {
  margin-top: -15px;

  :deep(.table_content) {
    padding: 10px 0;
  }

  .count_box {
    font-size: 16px;
  }
}
</style>
